`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: 
// Engineer: 
// 
// Create Date:    17:01:16 12/06/2008 
// Design Name: 
// Module Name:    TileIndex 
// Project Name: 
// Target Devices: 
// Tool versions: 
// Description: 
//
// Dependencies: 
//
// Revision: 
// Revision 0.01 - File Created
// Additional Comments: 
//
//////////////////////////////////////////////////////////////////////////////////
module TileIndex(
    input [4:0] Index,
    input clock,
   // input reset,
	 input en,
	 input [15:0] indexData,
	 input [4:0] readTileIndex,
	 output reg [15:0] tileIndexOut = 0
    );
	 /*
		TileIndex is a 30 words register which hold the index of the sprite of the whole row.
		input is from block ram 
		output to VGARead in order to get the right address of the pixel data store inside block ram.
	 */
reg [15:0]tiles[29:0];
//reg [4:0] i;
always@(posedge clock)
begin
//	if(reset)
	//	for(i = 0; i < 30; i = i + 1)
		//	tiles[i] <= 0;
	if(en)
		tiles[Index] <= indexData;
	tileIndexOut <= tiles[readTileIndex];
end

	
endmodule
